package com.kuang.pojo;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class MyTest {

    public static void main(String[] args) {
        //获取Spring的上下文对象！
//        ApplicationContext context = new ClassPathXmlApplicationContext("beans.xml");
        //我们的对象现在都在Spring中管理了，我们要使用，直接去里面取出来就可以！
//        User user0 = (User) context.getBean("user0");
//        System.out.println(user0.getName());
//
//        User user_by_index = (User) context.getBean("user_by_index");
//        System.out.println(user_by_index.getName());
//
//        User user_by_type = (User) context.getBean("user_by_type");
//        System.out.println(user_by_type.getName());

        ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
        User user0 = (User) context.getBean("u3");
        System.out.println(user0.getName());
    }
}
